home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Think Class Libraries / WASTE TCL 2.0b2 / WASTEEdit / Aliases / WASTE TCL 2.0 ƒ / CWASTEClipboard.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-21  |  2.9 KB  |  126 lines  |  [TEXT/SPM ]

  1. /******************************************************************************
  2.  CWASTEClipboard.cpp
  3.  
  4.      A derived class of CClipboard that displays 'TEXT', 'soup', and 'styl'
  5.  
  6.         To use this class in your application, you should override
  7.         CApplication::MakeClipboard, as in:
  8.  
  9.         void    CMyApp::MakeClipboard()
  10.         {
  11.             CWASTEClipboard    *wasteClip = TCL_NEW(CWASTEClipboard,(true));
  12.  
  13.             gClipboard = wasteClip;
  14.         }
  15.  
  16.  
  17.     By Dan Crevier, 1996
  18.  ******************************************************************************/
  19.  
  20. #ifdef TCL_PCH
  21. #include <TCLHeaders>
  22. #endif
  23.  
  24. #include "CWASTEClipboard.h"
  25. #include "CScrollPane.h"
  26. #include "Global.h"
  27.  
  28. #include "CWASTEText.h"
  29.  
  30. /******************************************************************************
  31.  CWASTEClipboard
  32.  
  33.      Constructor
  34. ******************************************************************************/
  35.  
  36. CWASTEClipboard::CWASTEClipboard(Boolean hasWindow)
  37.     : CClipboard(hasWindow)
  38. {
  39. }
  40.  
  41.  
  42. /******************************************************************************
  43.  IWASTEClipboard
  44.  
  45.      Initialize a CWASTEClipboard
  46. ******************************************************************************/
  47.  
  48. void CWASTEClipboard::IWASTEClipboard(CApplication *aSupervisor,
  49.                      Boolean hasWindow)
  50. {
  51.     CClipboard::IClipboard(aSupervisor, hasWindow);
  52. }
  53.  
  54.  
  55. /******************************************************************************
  56.  MakeClipView
  57.  
  58.      This method makes a panorama to display the current clipboard data.
  59.  
  60. ******************************************************************************/
  61.  
  62. CPanorama* CWASTEClipboard::MakeClipView(long dataType, Handle dataHandle)
  63. {
  64.     Handle        styleHandle = NULL;
  65. #if WASTE_VERSION >= 0x01100000
  66.     Handle        soupHandle = NULL;
  67. #endif
  68.     CWASTEText *volatile text = NULL;
  69.     Rect        margin;
  70.     CPanorama    *panorama = NULL;
  71.  
  72.     try_
  73.     {
  74.         if (dataType == 'TEXT')
  75.         {
  76.             GetData('styl', &styleHandle);
  77. #if WASTE_VERSION >= 0x01100000
  78.             GetData('SOUP', &soupHandle);
  79. #endif
  80.             text = TCL_NEW(CWASTEText,());
  81.  
  82.             text->IWASTEText(itsScrollPane, this,
  83.                         1, 1, 0, 0, sizELASTIC, sizELASTIC, 1000);
  84.             text->Specify(kNotEditable, kNotSelectable, kNotStylable);
  85.             text->FitToEnclosure(TRUE, TRUE);
  86.             text->Offset(2, 2, FALSE);
  87.             SetRect(&margin, 0, 0, -2, -2);
  88.             text->ChangeSize(&margin, FALSE);
  89.  
  90.             MoveHHi(dataHandle);
  91.             HLock(dataHandle);
  92.  
  93.  
  94. #if WASTE_VERSION >= 0x01100000
  95.             text->InsertWithStyleSoup(*dataHandle, GetHandleSize(dataHandle),
  96.                         (StScrpHandle) styleHandle, soupHandle, true);
  97. #else
  98.             text->InsertWithStyle(*dataHandle, GetHandleSize(dataHandle),
  99.                         (StScrpHandle) styleHandle, true);
  100. #endif
  101.             TCLForgetHandle(dataHandle);
  102.             TCLForgetHandle(styleHandle);
  103. #if WASTE_VERSION >= 0x01100000
  104.             TCLForgetHandle(soupHandle);
  105. #endif
  106.             panorama = text;
  107.         }
  108.     }
  109.     catch_all_()
  110.     {
  111.         if (dataType == 'TEXT')
  112.         {
  113.             TCLForgetObject(text);
  114.             TCLForgetHandle(dataHandle);
  115.             TCLForgetHandle(styleHandle);
  116. #if WASTE_VERSION >= 0x01100000
  117.             TCLForgetHandle(soupHandle);
  118. #endif
  119.         }
  120.         throw_same_();
  121.     }
  122.     end_try_
  123.  
  124.     return panorama;
  125. }
  126.